from db import db1
class RBAC:
    def __init__(self):
        pass
    # 查询用户资源
    def get_user_resouce(self,uid,type):
        sql = "select r.id,r.name,r.url,pr.id as pid,pr.name as pname from user_role as ur left join role_resource as rr on ur.roleid=rr.roleid left join resource as r on rr.resource=r.id left join resource as pr on pr.id=r.pid where ur.userid=%d and r.type=%d"%(int(uid),int(type))
        res = db1.find_all(sql)
        return res
rbac = RBAC()